package com.orangelife.main;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.orangelife.R;

import java.util.HashMap;
import java.util.List;

/**
 * 列表适配器
 * Created by ZeroVoid on 2018-7-25.
 */
public class MainListAdapter extends BaseAdapter {

    private List<HashMap<String, Class>> mData;
    private Context mCtx;


    public MainListAdapter(Context ctx, List<HashMap<String, Class>> data) {
        this.mCtx = ctx;
        this.mData = data;
    }

    @Override
    public int getCount() {
        return mData == null ? 0 : mData.size();
    }

    @Override
    public Object getItem(int i) {
        return mData == null ? null : mData.get(i);
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {
        LayoutInflater inflater = LayoutInflater.from(mCtx);
        ViewHolder holder;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.main_item_list, null);
            holder = new ViewHolder();
            holder.tvActName = convertView.findViewById(R.id.tvActName);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        HashMap<String, Class> map = mData.get(i);
//        holder.tvActName.setText(map.);
        return convertView;
    }

    class ViewHolder {
        TextView tvActName;
    }
}
